﻿<Window x:Class="migradorWPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Migrador Base de Datos - ZEKE" Height="650" Width="790" Background="#f5f5f5"
        Icon="zekelogo.ico">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <!-- configuracion -->
        <Grid Grid.Row="0" Margin="5">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <!-- seleccion de tipo bd -->
            <TextBlock Grid.Row="0" Grid.Column="0" Text="Tipo de BD:"/>
            <ComboBox IsEnabled="{Binding CmbEnabled}" Grid.Row="0" Grid.Column="1" ItemsSource="{Binding BasesDeDatosSoportadas}" SelectedItem="{Binding BaseDeDatosSelected, Mode=TwoWay}"/>
                
            <!-- Host -->
            <TextBlock Grid.Row="1" Grid.Column="0" Text="Host:"/>
            <TextBox  IsReadOnly="{Binding Conectado}" Background="{Binding ColorDisabled}" Grid.Row="1" Grid.Column="1" Text="{Binding Host, Mode=TwoWay}"/>
            
            <!-- puerto -->
            <TextBlock Grid.Row="2" Grid.Column="0" Text="Puerto:"/>
            <TextBox IsReadOnly="{Binding Conectado}" Background="{Binding ColorDisabled}" Grid.Row="2" Grid.Column="1" Text="{Binding Port, Mode=TwoWay}"/>

            <!-- nombre BD -->
            <TextBlock Grid.Row="3" Grid.Column="0" Text="Nombre BD:"/>
            <TextBox IsReadOnly="{Binding Conectado}" Background="{Binding ColorDisabled}" Grid.Row="3" Grid.Column="1" Text="{Binding NombreBD, Mode=TwoWay}" />

            <!-- User -->
            <TextBlock Grid.Row="0" Grid.Column="2" Text="Usuario:"/>
            <TextBox IsReadOnly="{Binding Conectado}" Background="{Binding ColorDisabled}" Grid.Row="0" Grid.Column="3" Text="{Binding Usuario, Mode=TwoWay}"/>

            <!-- Password -->
            <TextBlock Grid.Row="1" Grid.Column="2" Text="Contraseña:"/>
            <TextBox IsReadOnly="{Binding Conectado}" Background="{Binding ColorDisabled}" Grid.Row="1" Grid.Column="3" Text="{Binding Contrasena, Mode=TwoWay}"/>
            
            <!-- botones -->
            <Button Grid.Row="4" Grid.Column="0" Content="Desconectar " Command="{Binding DesconectarCommand}"/>
            <Button Grid.Row="4" Grid.Column="1" Content="Conectar" Command="{Binding ConnectDataBaseCommand}"/>
        </Grid>
        
        <!-- parches -->
        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            
            <!-- seleccionar directorio parches -->
            <StackPanel Grid.Row="0" Orientation="Horizontal">
                <TextBlock Text="Directorio de scripts" />
                <Button IsEnabled="{Binding Conectado}" Width="20" Height="20" x:Name="btnSeleccionarDirParches" Click="btnSeleccionarDirParches_Click"/>
                <TextBox Width="200" IsReadOnly="True" x:Name="txtDirParches" />
                <CheckBox x:Name="chkProcedimientosAlmacenados" Content="Procedimientos almacenados" IsChecked="{Binding ProcedimientosAlmacenados}" Click="chkProcedimientosAlmacenados_Click"/>
                <Button x:Name="btnAplicarParches" Content="Aplicar parches" Command="{Binding AplicarParchesCommand}" />
                <Button x:Name="btnCancelarAplicarParches" Content="Cancelar" Command="{Binding CancelarAplicarParchesCommand}"/>
                <TextBlock x:Name="txtMensajes" Text="{Binding MensajesAplicacion}"/>
            </StackPanel>
            

         
                <Grid Grid.Row="1">
                    <!-- definicion de la grilla-->
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    
                    <!-- parches no aplicados -->
                    <StackPanel Grid.Row="0" Grid.Column="0" >
                        <TextBlock Text="Parches no Aplicados"/>
                    </StackPanel>
                    <DataGrid Grid.Row="1" 
                              Grid.Column="0" 
                              ItemsSource="{Binding Parches}" 
                              IsReadOnly="True" 
                              AutoGenerateColumns="False" 
                              ScrollViewer.CanContentScroll="True" 
                              ScrollViewer.VerticalScrollBarVisibility="Auto">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Nombre" Binding="{Binding Nombre}"  Width="*"/>
                            <DataGridTextColumn Header="Fecha Modificación" Binding="{Binding UltimaModificacion}" Width="*" />
                            <DataGridTextColumn Header="Tamaño" Binding="{Binding Tamanio}" Width="*"/>
                        </DataGrid.Columns>
                    </DataGrid>
                    <!-- parches aplicados -->
                    <StackPanel Grid.Row="0" Grid.Column="1">
                        <TextBlock Text="Parches Aplicados"/>
                    </StackPanel>
                    <DataGrid Grid.Row="1" 
                              Grid.Column="1" 
                              ItemsSource="{Binding ParchesAplicados}"                                   
                              IsReadOnly="True" 
                              AutoGenerateColumns="False" 
                              ScrollViewer.CanContentScroll="True" 
                              ScrollViewer.VerticalScrollBarVisibility="Auto">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Nombre" Binding="{Binding Nombre_parche}" Width="*"/>
                            <DataGridTextColumn Header="Fecha Aplicación" Binding="{Binding Fecha_aplicacion}" Width="*"/>
                            <DataGridTextColumn Header="Aplicador Por" Binding="{Binding Aplicado_por}" Width="*"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            
        </Grid>
        
        <!-- Salida de las operaciones-->
        <Grid Grid.Row="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <StackPanel Grid.Row="0" HorizontalAlignment="Left">
                <Button x:Name="btnLimparConsola" Content="Limpiar resultados" Width="100" Click="btnLimparConsola_Click"/>    
            </StackPanel>
            
            <TextBox x:Name="txtConsola" Grid.Row="1" TextWrapping="Wrap" IsReadOnly="True" AcceptsReturn="True" Text="{Binding LogSalidaPantalla}"/>
        </Grid>
    </Grid>
</Window>
